﻿
@{
    ViewBag.Title = "修改商品";
}
@model RXY_Mall.Application.Goods.Dto.GoodsInput
@section CSS{
    <link href="~/Content/css/layerui/layui.css" rel="stylesheet" />
    <link href="~/Content/js/UploadImg/css/webuploader.css" rel="stylesheet" />
    <link href="~/Content/js/UploadImg/css/goodsupload.css" rel="stylesheet" />
}
<div class="content-wrapper">
    <section class="content-header">
        <h1>
            商品
            <small>信息</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">商品管理</a></li>
            <li><a href="#">商品列表</a></li>
            <li class="active">商品信息</li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                @if (null != Model && Model.id > 0)
                {
                    <div class="nav-tabs-custom">
                        <ul class="nav nav-tabs">
                            <li class="active"><a href="/goods/editgoods/@Model.id" data-toggle="tab" aria-expanded="true">基本信息</a></li>
                            @*<li class=""><a href="/goods/GoodsSpec/@Model.id">商品规格</a></li>*@
                            <li class=""><a href="/goods/GoodsSku/@Model.id">商品SKU</a></li>
                        </ul>
                        <div class="box tab-content">
                            <div class="box-body ">
                                <div class="ibox float-e-margins">
                                    <div class="ibox-content contenttab0">
                                        <form class="form-horizontal" id="form-add" novalidate="novalidate" method="post" action="/goods/AddorEditGoodsInfo">
                                            <input type="hidden" id="id" name="id" value="@Model.id" />
                                            <input type="hidden" id="shop_id" name="shop_id" value="@Model.shop_id" />
                                            <input type="hidden" id="type_id" name="type_id" value="@Model.type_id" />
                                            <input type="hidden" id="category_id" name="category_id" value="@Model.category_id" />
                                            <input type="hidden" id="category_id1" name="category_id1" value="@Model.category_id1" />
                                            <input type="hidden" id="category_id2" name="category_id2" value="@Model.category_id2" />
                                            <div class="col-md-12">
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">商品编号 <span style="color:red;">*</span>：</label>
                                                    <div class="col-sm-10">
                                                        <label class="control-label">@Model.id</label>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">商品名称 <span style="color:red;">*</span>：</label>
                                                    <div class="col-sm-10">
                                                        <input type="text" name="name" id="name" maxlength="130" class="form-control" placeholder="请输入商品名称" value="@Model.name" required="" aria-required="true">
                                                        <span class="help-block m-b-none">商品名称最多不超过130个字</span>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">品牌 <span style="color:red;">*</span>：</label>
                                                    <div class="col-sm-3">
                                                        <input type="text" name="brand" id="brand" maxlength="30" required="" class="form-control" placeholder="请输入商品品牌" value="@Model.brand">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">商品卖点：</label>
                                                    <div class="col-sm-10">
                                                        <input type="text" name="summary" id="summary" maxlength="250" class="form-control" placeholder="请输入商品简介" value="@Model.summary">
                                                        <span class="help-block m-b-none">最多不超过250个字</span>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">@(Model.type_id == 2 ? "结算价(元)" : "平台销售价(元)" )<span style="color:red;">*</span>：</label>
                                                    <div class="col-sm-3">
                                                        <input type="text" name="sale_price" id="sale_price" class="form-control" placeholder="请输入价格" required="" aria-required="true" number="true" value="@Model.sale_price">
                                                        <span class="help-block m-b-none"></span>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">市场价(元) <span style="color:red;">*</span>：</label>
                                                    <div class="col-sm-3">
                                                        <input type="text" name="market_price" id="market_price" class="form-control" placeholder="请输入市场价格" required="" aria-required="true" number="true" value="@Model.market_price">
                                                        <span class="help-block m-b-none"></span>
                                                    </div>
                                                </div>
                                                <div class="form-group" style="display:none">
                                                    <label class="col-sm-2 control-label">订单最大可买数量：</label>
                                                    <div class="col-sm-3">
                                                        <input type="text" name="limit_quantity" id="limit_quantity" class="form-control" placeholder="" required="" value="@(Model.limit_quantity>0?Model.limit_quantity:999)" aria-required="true" number="true">
                                                        <span class="help-block m-b-none"></span>
                                                    </div>
                                                    <label class="col-sm-2 control-label">通知管理员数量：</label>
                                                    <div class="col-sm-3">
                                                        <input type="text" name="notify_admin_quantity" id="notify_admin_quantity" class="form-control" placeholder="" value="@(Model.notify_admin_quantity>0?Model.notify_admin_quantity:10)" required="" aria-required="true" number="true">
                                                        <span class="help-block m-b-none"></span>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">排序：</label>
                                                    <div class="col-sm-3">
                                                        <input type="text" name="sort" id="sort" number="true" aria-required="false" class="form-control" value="@(Model.sort>0?Model.sort:99)" placeholder="请输入排序数">
                                                    </div>
                                                </div>
                                                <div class="form-group" style="display:none">
                                                    <label class="col-sm-1 control-label"></label>
                                                    <div class="col-sm-3">
                                                        <label class="control-label"><input type="checkbox" name="is_new" id="is_new" value="@Model.is_new" checked="@Model.is_new" class="i-checks">是否新品</label> &nbsp;&nbsp;
                                                        <label class="control-label"><input type="checkbox" name="is_top" id="is_top" value="@Model.is_top" checked="@Model.is_top" class="i-checks">是否置顶</label> &nbsp;&nbsp;
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <input type="hidden" name="goods_service" id="goods_service" value="">
                                                    <input type="hidden" name="goods_service_list" id="goods_service_list" value="">
                                                    <label class="col-sm-2 control-label">商品服务：</label>
                                                    <div class="col-sm-10" id="services">

                                                    </div>
                                                </div>
                                                <div class="hr-line-dashed"></div>
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">商品图片：</label>
                                                    <div class="col-sm-10">
                                                        <div id="uploader0" class="goodsuploader">
                                                            <div class="item_container">
                                                                <div class="queueList" id="queueList0">
                                                                    <div id="dndArea0" class="placeholder">
                                                                        <div id="filePicker01" style="line-height:12px;margin-bottom:5px;"></div>
                                                                    </div>
                                                                    <ul id="filelist0" class="filelist"></ul>
                                                                </div>
                                                            </div>
                                                            <div class="statusBar" id="statusBar0" style="display:none;">
                                                                <div class="progress" id="progress0">
                                                                    <span class="text">0%</span>
                                                                    <span class="percentage"></span>
                                                                </div><div class="info" id="info0"></div>
                                                                <div class="btns">
                                                                    <div id="filePicker02"></div><div class="uploadBtn" id="uploadBtn0">开始上传</div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <span class="help-block m-b-none">最多可上传 6 张图片，每张大小不超过 1 M</span>
                                                    </div>
                                                </div>
                                                <div class="hr-line-dashed"></div>
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">商品描述：</label>
                                                    <div class="col-sm-10">
                                                        <textarea name="description" id="description" maxlength="500" class="form-control" placeholder="请输入商品描述" rows="3">@Model.description</textarea>
                                                        <span class="help-block m-b-none"></span>
                                                    </div>
                                                </div>
                                                <div class="hr-line-dashed"></div>
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">内容图片：</label>
                                                    <div class="col-sm-10">
                                                        <div id="uploader1" class="goodsuploader">
                                                            <div class="item_container">
                                                                <div class="queueList" id="queueList1">
                                                                    <div id="dndArea1" class="placeholder">
                                                                        <div id="filePicker11" style="line-height:12px;margin-bottom:5px;"></div>
                                                                    </div>
                                                                    <ul id="filelist1" class="filelist"></ul>
                                                                </div>
                                                            </div>
                                                            <div class="statusBar" id="statusBar1" style="display:none;">
                                                                <div class="progress" id="progress1">
                                                                    <span class="text">0%</span>
                                                                    <span class="percentage"></span>
                                                                </div><div class="info" id="info1"></div>
                                                                <div class="btns">
                                                                    <div id="filePicker12"></div><div class="uploadBtn" id="uploadBtn1">开始上传</div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <span class="help-block m-b-none">最多可上传 30 张图片，每张大小不超过 1 M</span>
                                                    </div>
                                                </div>
                                                <div class="hr-line-dashed"></div>
                                                @if (Model.type_id == 1)
                                                {
                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label">服务费率(％)：</label>
                                                        <div class="col-sm-1">
                                                            <input type="text" name="service_rate" id="service_rate" value="@Model.service_rate" digits="true" class="form-control" placeholder="请输入服务费率" required="" aria-required="true" number="true">
                                                            <span class="help-block m-b-none"></span>
                                                        </div>
                                                        <label class="col-sm-2 control-label">红包比例%：</label>
                                                        <div class="col-sm-1">
                                                            <input type="text" name="red_packet" id="red_packet" value="@Model.red_packet" digits="true" aria-required="false" class="form-control" placeholder="请输入红包比例">
                                                        </div>
                                                        @*</div>
                    <div class="form-group">*@
                                                        <label class="col-sm-2 control-label">拼团人数：</label>
                                                        <div class="col-sm-1">
                                                            <input type="text" name="require_num" id="require_num" number="true" value="@Model.require_num" aria-required="false" class="form-control" placeholder="请输入人数">
                                                        </div>
                                                        <label class="col-sm-2 control-label">拼团时长(小时)：</label>
                                                        <div class="col-sm-1">
                                                            <input type="text" name="duration" id="duration" number="true" value="@Model.duration" aria-required="false" class="form-control" placeholder="请输入时长">
                                                        </div>
                                                    </div>
                                                    <div class="form-group" style="display:none">
                                                        <label class="col-sm-2 control-label">活动日期：</label>
                                                        <div class="col-sm-3">
                                                            <input type="text" name="start_time" id="start_time" value="@(Model.start_time.ToString("yyyy-MM-dd")) " placeholder="开始日期" required="" aria-required="true" class="form-control pull-right ">
                                                            <span class="help-block m-b-none"></span>
                                                        </div>
                                                        <label style="float:left;"> - </label>
                                                        <div class="col-sm-3">
                                                            <input type="text" name="end_time" id="end_time" placeholder="结束日期" value="@(Model.end_time==null?"":((DateTime)Model.end_time).ToString("yyyy-MM-dd"))" class="form-control pull-right">
                                                            <span class="help-block m-b-none"></span>
                                                        </div>
                                                    </div>
                                                }
                                                else if (Model.type_id == 2)
                                                {
                                                    <input type="hidden" id="service_rate" name="service_rate" value="0" />
                                                    <input type="hidden" name="red_packet" id="red_packet" value="0">
                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label">人数：</label>
                                                        <div class="col-sm-3">
                                                            <input type="text" name="require_num" id="require_num" number="true" value="@Model.require_num" aria-required="false" class="form-control" placeholder="请输入人数">
                                                        </div>
                                                        <label class="col-sm-3 control-label">时长(小时)：</label>
                                                        <div class="col-sm-3">
                                                            <input type="text" name="duration" id="duration" number="true" value="@Model.duration" aria-required="false" class="form-control" placeholder="请输入时长">
                                                        </div>
                                                    </div>
                                                    <div class="form-group" style="display:none">
                                                        <label class="col-sm-2 control-label">活动日期：</label>
                                                        <div class="col-sm-3">
                                                            <input type="text" name="start_time" id="start_time" value="@(Model.start_time.ToString("yyyy-MM-dd"))" placeholder="开始日期" required="" aria-required="true" class="form-control pull-right ">
                                                            <span class="help-block m-b-none"></span>
                                                        </div>
                                                        <label style="float:left;"> - </label>
                                                        <div class="col-sm-3">
                                                            <input type="text" name="end_time" id="end_time" value="@(Model.end_time==null?"":((DateTime)Model.end_time).ToString("yyyy-MM-dd"))" placeholder="结束日期" class="form-control pull-right">
                                                            <span class="help-block m-b-none"></span>
                                                        </div>
                                                    </div>
                                                }
                                                else
                                                {
                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label">服务费率(％)：</label>
                                                        <div class="col-sm-1">
                                                            <input type="text" name="service_rate" id="service_rate" digits="true" class="form-control" placeholder="请输入服务费率" required="" value="@Model.service_rate" aria-required="true" number="true">
                                                            <span class="help-block m-b-none"></span>
                                                        </div>
                                                    </div>
                                                    <input type="hidden" name="red_packet" id="red_packet" value="0">
                                                    <input type="hidden" id="require_num" name="require_num" value="0" />
                                                    <input type="hidden" name="duration" id="duration" value="0">
                                                    <input type="hidden" id="start_time" name="start_time" value="@ViewBag.NowTime" />
                                                }
                                                <div class="form-group" style="display:none">
                                                    <label class="col-sm-3 control-label">备注：</label>
                                                    <div class="col-sm-9">
                                                        <textarea name="remark" id="remark" maxlength="500" class="form-control" placeholder="请输入备注" rows="3">@Model.remark</textarea>
                                                        <span class="help-block m-b-none"></span>
                                                    </div>
                                                </div>
                                                <div class="hr-line-dashed"></div>
                                                @*<div class="form-group">
                                                    <div class="col-sm-4 col-sm-offset-2">
                                                        <button class="btn btn-primary" onclick="btnEditGoods()" type="button">保存内容</button>
                                                    </div>
                                                </div>*@
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                }
                else
                {
                    <div style="text-align:center;padding-bottom:100px;font-weight:bolder;">商品不存在，请重试！</div>
                }
            </div>
        </div>
    </section>

</div>

@section JS{
    <script src="~/Content/js/jquery.form.js"></script>
    <script src="~/Content/plugins/validate/jquery.validate.min.js"></script>
    <script src="~/Content/plugins/validate/messages_zh.min.js"></script>
    <script src="~/Content/js/UploadImg/js/webuploader.js"></script>
    <script src="~/Content/js/UploadImg/js/jquery.sortable.js"></script>
    <script>
        var g_id=@Model.id;
        var s_id=@Model.shop_id;
    </script>
    @*<script src="~/Content/js/UploadImg/js/goodsUpload.js"></script>
    <script src="~/Content/js/UploadImg/js/goodsContentUpload.js"></script>*@
    <script>
        $(function(){
            setGoodsService();
            GetImgList0(g_id);
            GetImgList1(g_id);
            $('#start_time').datepicker({
                autoclose: true
            });

            $('#end_time').datepicker({
                autoclose: true
            });
           $("#is_new").change(function() {
              var obj=$(this);
              if(obj.is(':checked')){obj.val("true")}
              else{obj.val("false")}
            });
           $("#is_top").change(function() {
              var obj=$(this);
              if(obj.is(':checked')){obj.val("true")}
              else{obj.val("false")}
            });
        });
        var goods_service='@Model.goods_service';
        var addService = [];
        $("#goods_service").val(goods_service);

    </script>
    <script src="~/Content/js/goods.js"></script>
}


